import router from "@/router";
import { useUserStore } from "@/store/user";
export function logoutFn(before?:()=>void,after?:()=>void){
    const store = useUserStore();
    // 有传入再调用
    before && before();
    localStorage.removeItem("token");
    store.routes.forEach((item)=>router.removeRoute(item.name));
    // 清仓库
    store.username="";
    store.menus = [];
    // 跳转到login
    router.push("/login");
    // 调用callback
    after && after();
}